import {Config} from '../../utils/conf.js';
import {httpReq} from '../../utils/http.js';

class editans
{
  getans(that,aid){
    let obj = {};
    //判断类型
    obj.url = Config.getoneans + aid;
    httpReq(obj).then(res=>{
      that.setData({
        anscon: res.data.data.answer,
      })
    })
  }
 
  //提交编辑的答案
  edit(answer,aid){
    let obj = {};
    obj.url = Config.updateans + aid;
    obj.method = 'put';
    obj.data = {
      answer
    };
    httpReq(obj).then(res => {
      if(res.data.state == 0){
        wx.showToast({
          title: '修改成功',
          icon: 'success',
        })
        setTimeout(()=>{wx.navigateTo({url: '/pages/list/list?ty=a'})},3000);
      }else{
        wx.showToast({
          title: res.data.msg,
          icon: 'none',
        })
      }
    })
  }
  
}

export default editans;